<template>
    <div>
        <table class="table">
            <thead>
                <tr>
                    <td>房间类型</td>
                    <td>
                        <select v-model="obj.houseTypeId">
                            <option value="0">请选择</option>
                            <option v-for="item in typelist" :value="item.id">{{ item.typeName }}</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>房号</td>
                    <td>
                        <input v-model="obj.houseNo" type="text">
                    </td>
                </tr>
                <tr>
                    <td>备注</td>
                    <td>
                        <textarea v-model="obj.remark"></textarea>
                    </td>
                </tr>
                <tr>
                    <td>是否删除</td>
                    <td>
                        <input v-model="obj.isDelete" type="checkbox" >选中为删除
                    </td>
                </tr>
                <tr>
                    <td>是否启用</td>
                    <td>
                        <input v-model="obj.isActive" type="radio" name="isActive" :value="true">启用
                        <input v-model="obj.isActive" type="radio" name="isActive" :value="false">禁用
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="button" value="编辑" @click="add" class="btn">
                    </td>
                </tr>
            </thead>
        </table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { onMounted, ref } from 'vue';
import { useRoute, useRouter } from 'vue-router';
const route=useRoute();
const router=useRouter();

onMounted(()=>{
    GetTypelist();
    GetData();
})
//根据编号读取房号数据
const GetData=()=>{
     var id = route.query.id;
     axios.get("https://localhost:7275/api/HouseNum/GetHouseNumId",{params:{id:id}}).then(res=>{
        obj.value = res.data;
        debugger
     })
}
const m={
    "id": "string",
    "typeName": "string",
    "price": 0,
    "number": 0,
    "area": 0,
    "window": true,
    "img": "string",
    "photoisDeleted": true,
    "createDate": "2025-02-10T11:42:22.195Z",
    "updateDate": "2025-02-10T11:42:22.195Z",
    "desc": "string",
    "numberCount": 0
}
const typelist=ref([m])

const GetTypelist=()=>{
  axios.get("https://localhost:7275/api/HouseType/GetHouseType").then(res=>{
    typelist.value=res.data;
  })
}

const obj=ref({
    "hI_Id": 0,
    "houseTypeId": 0,
    "houseNo": "",
    "remark": "",
    "isDelete": true,
    "isActive": true
})
const add=()=>{
    axios.put("https://localhost:7275/api/HouseNum/UpdateHouseNum",obj.value).then(res=>{
        if(res.data>0){
            alert('修改成功')
            router.push({path: '/Show'});
        }
        else{
            alert('修改失败');
        }
    })
}
</script>

<style scoped>

</style>